package com.tanhua.manage.listener;

import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
  
import java.nio.charset.StandardCharsets;
  
/**
 * @program: SpringCloud
 * @description: redis Key过期监听
 * @author: zhang yi
 * @create: 2020-03-24 14:14
 */
@Slf4j
public class KeyExpiredListener extends KeyExpirationEventMessageListener {
  
 public KeyExpiredListener(RedisMessageListenerContainer listenerContainer) {
  super(listenerContainer);
 }
  
 @Override
 public void onMessage(Message message, byte[] pattern) {
  System.out.println("过期key:" + message.toString());
 }
}